var tools = {
    name: 'zhang',
    playMusic: function() {
        media.playMusic("/sdcard/Download/WeiXin/music.mp3");
        let timer = setInterval(() => {clearInterval(timer)}, media.getMusicDuration())
    },
    playLongMusic: function() {
        media.playMusic("/sdcard/Download/WeiXin/ningsheng.mp3");
        setTimeout(()=> {}, media.getMusicDuration())
    },
    move: function() {
        floatyWin.on("touch", function(event) {
            if (event.action === "down") {
                // 记录触摸开始的位置
                touchStartX = event.getRawX();
                touchStartY = event.getRawY();
                isDragging = true;
            } else if (event.action === "move" && isDragging) {
                // 计算触摸移动的距离
                var deltaX = event.getRawX() - touchStartX;
                var deltaY = event.getRawY() - touchStartY;
                
                // 更新浮窗的位置
                floatyWin.setPosition(currentX + deltaX, currentY + deltaY);
                
                // 更新当前位置为新的位置
                currentX += deltaX;
                currentY += deltaY;
                
                // 更新触摸开始的位置，以便下一次移动计算正确
                touchStartX = event.getRawX();
                touchStartY = event.getRawY();
            } else if (event.action === "up" || event.action === "cancel") {
                // 停止拖动
                isDragging = false;
            }
        });
        
    }
}

module.exports = tools